
@include('public.page_styles')

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
@include('public.top')
  <!-- Left side column. contains the logo and sidebar -->
@include('public.sidebar')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        {{ trans('message.usersTitle') }}
        <small>{{ trans('message.add') }}</small>
      </h1>
      <ol class="breadcrumb">
        <li><a ><i class="fa fa-dashboard"></i> {{ trans('message.home') }}</a></li>
        <li><a href="{{ url('user/list') }}"> {{ trans('message.usersTitle') }} {{ trans('message.list') }}</a></li>
        <li class="active">{{ trans('message.usersTitle') }}{{ trans('message.add') }}</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"> {{ trans('message.add') }}</h3>
              <div class="box-tools">
                <div class="btn-group pull-right" style="margin-right: 10px">
                  <a href="{{ url('user/list') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp; {{ trans('message.list') }}</a>
                </div>
                <div class="btn-group pull-right" style="margin-right: 10px">
                  <a class="btn btn-sm btn-default form-history-back" onclick="goBack()" ><i class="fa fa-arrow-left"></i>&nbsp;{{ trans('message.history-back') }}</a>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form name="createForm" action="{{url('user/')}}" method="post"  class="form-horizontal" autocomplete="off">
              <input type="hidden" name="_token" value="{{ csrf_token() }}">
              <div class="box-body">
                <div id="nameDiv" class="form-group {!! !$errors->has('name') ?: 'has-error' !!}" >
                  <label for="name" class="col-sm-2 control-label">账号</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="text" class="form-control" id="name" name="name" placeholder="账号" value="{{ old('name') }}"    >
                    @if($errors->has('name'))
                      @foreach($errors->get('name') as $message)
                        <label id="nameError" class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>
                {{--取消input框的默认自动填充--}}
                <input type="text" name="type" id="type" style="height: 0;opacity: 0;position: absolute;">
                <input id="password" type="password" name="password" style="height: 0;opacity: 0;position: absolute;">

                <div class="form-group {!! !$errors->has('email') ?: 'has-error' !!}">
                  <label for="email" class="col-sm-2 control-label">邮箱</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="email" class="form-control"  name="email" placeholder="Email" value="{{ old('email') }}"  autocomplete="off"  >
                    @if($errors->has('email'))
                      @foreach($errors->get('email') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group {!! !$errors->has('password') ?: 'has-error' !!}">
                  <label for="password" class="col-sm-2 control-label">密码</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="password" class="form-control"  name="password" placeholder="Password" value="{{ old('password') }}" autocomplete="off" >
                    @if($errors->has('password'))
                      @foreach($errors->get('password') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group {!! !$errors->has('username') ?: 'has-error' !!}">
                  <label for="username" class="col-sm-2 control-label">姓名</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" id="username" name="username" placeholder="姓名" value="{{ old('username') }}"  >
                    @if($errors->has('username'))
                      @foreach($errors->get('username') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-2 control-label">角色</label>
                  <div class="col-sm-8">
                    <select class="form-control" name="role_id">
                      <option value="2">默认用户组</option>
                      @if($roles)
                        @foreach($roles as $role)
                          <option value="{{ $role->id }}">{{ $role->role_name }}</option>
                        @endforeach
                      @endif
                    </select>
                  </div>
                </div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <div class="col-sm-2">
                </div>
                <div class="col-sm-8">
                  <div class="btn-group pull-right">
                    <button type="button" class="btn btn-info pull-right btn-js-form-submit" >提交</button>
                  </div>
                  <div class="btn-group pull-left">
                    <button type="reset" class="btn btn-warning">撤销</button>
                  </div>
                </div>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
        </div>
        <!--/.col (right) -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
@include('public.bottom')

  <!-- Control Sidebar -->
{{--@include('public.aside')--}}
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

@include('public.javascript')

<script type="text/javascript">
jQuery(function ($) {
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': '{{ csrf_token() }}'
        }
    });

    @if(session()->has('fail'))
      alertMess("{{session()->get('fail')}}");
    @endif

});


var _ajaxSubmitSending = false;
$(".btn-js-form-submit").click(function (e) {
    if (_ajaxSubmitSending) {
        return;
    } else {
        _ajaxSubmitSending = true;
        _loadingFuc();
    }
    $('form[name="createForm"]').submit();
    _ajaxSubmitSending = false;
    setTimeout(function(){
        $.unblockUI();
    }, 1500);
});


$(function(){

//    _pager.find('.jq-first-page').addClass('disabled');
//    _pager.find('.jq-first-page').removeClass('disabled');
//    $("#nameError").hide();
//    $('#nameDiv').removeClass('has-error');
//    $("#postCodeError").html(error).show();
//    $('#postCodeDiv').addClass('has-error');


    /*$('#name').change(function () {
      var name=$('#name').val();
      alert(name);

      if(2<= name.length <= 20 ){

      }

      // 检查名称是否存在
        $.ajax({
            type:'',
            url:'',
            data:{},
            success:function(response){
              alert(response);
            },
            error:function () {}
        });

    })*/

})



</script>

</body>
</html>
